<template>
  <a-modal
    :title="title"
    :width="450"
    :body-style="{height: '150px'}"
    :footer="null"
    @cancel="close"
    :visible="visible">

    <a-select v-model="language" @change="changeLanguage" style="width: 100%;" :options="lang">
    </a-select>

  </a-modal>

</template>

<script>

import store from '@/store/'
import YchConstant from "../../api/YchConstant";

export default {
  name: 'LanguageSelect',
  data() {
    return {
      title: this.$t('m.system.portal.entity.switchLanguage'),
      visible: false,
      language: store.getters.language,
      lang: YchConstant.LANG,
    }
  },
  methods: {
    changeLanguage(language) {
      this.language = language
      this.$store.dispatch('setLanguage', {language, i18n: this.$i18n})
    },
    show() {
      this.visible = true
    },
    close() {
      this.visible = false
    },
  }
}
</script>

